/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2024-03-05
 * Time:9:11
 */
public class Solution {
    public class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }

 public ListNode deleteDuplicates(ListNode head) {
        if(head == null || head.next == null) return head;
        ListNode prev = head,cur = head.next;
        while(cur != null) {
            if(cur.val != head.val)
                prev = cur;
            cur = cur.next;
        }
        return null;
    }

    public static void sortColors(int[] nums) {
        int left = -1,right = nums.length;
        int i = 0;
        while(i < right) {
            if(nums[i] == 0) {
                ++left;
                int tmp = nums[left];
                nums[left] = nums[i];
                nums[i] = tmp;
                i++;
            } else if(nums[i] == 1) {
                i++;
            } else {
                --right;
                int tmp = nums[right];
                nums[right] = nums[i];
                nums[i] = tmp;
            }
        }
    }

}
